﻿using System.Collections;
using System.Collections.Generic;
using Wintellect.PowerCollections;

public class PriorityQueue<T> : IEnumerable<T>
{
    private OrderedBag<T> priorityQueue; 

    public PriorityQueue()
    {
        priorityQueue = new OrderedBag<T>();
    }

    public IEnumerator<T> GetEnumerator()
    {
        foreach (var item in priorityQueue)
        {
            yield return item;
        }
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return this.GetEnumerator();
    }

    public void Add(T item)
    {
        priorityQueue.Add(item);
    }

    public T GetFirst()
    {
        T firstItem = priorityQueue.RemoveFirst();
        return firstItem;
    }

    public T this[int index]
    {
        get
        {
            T item = priorityQueue[index];
            return item;
        }
    }
}

